package controller

import (
	"admin/model"
	"common/helper"
	"github.com/valyala/fasthttp"
)

type PromoInspectionController struct{}

// 充值配置列表
func (that PromoInspectionController) List(ctx *fasthttp.RequestCtx) {

	page := ctx.QueryArgs().GetUintOrZero("page")
	pageSize := ctx.QueryArgs().GetUintOrZero("page_size")
	uid := string(ctx.QueryArgs().Peek("uid"))

	s, err := model.PromoInspectionList(uint(page), uint(pageSize), uid)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}

	helper.RetData(ctx, true, s)
}

// 渠道打码记录列表
func (that PromoInspectionController) MerchantList(ctx *fasthttp.RequestCtx) {

	page := ctx.QueryArgs().GetUintOrZero("page")
	pageSize := ctx.QueryArgs().GetUintOrZero("page_size")
	uid := string(ctx.QueryArgs().Peek("uid"))
	operatorId := string(ctx.QueryArgs().Peek("operator_id"))

	if operatorId == "" {
		helper.RetData(ctx, false, helper.OperatorIdErr)
		return
	}
	s, err := model.MerchantPromoInspectionList(uint(page), uint(pageSize), uid, operatorId)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}

	helper.RetData(ctx, true, s)
}

// 业务员打码记录列表
func (that PromoInspectionController) BusinessList(ctx *fasthttp.RequestCtx) {

	page := ctx.QueryArgs().GetUintOrZero("page")
	pageSize := ctx.QueryArgs().GetUintOrZero("page_size")
	uid := string(ctx.QueryArgs().Peek("uid"))
	businessId := string(ctx.QueryArgs().Peek("business_id"))

	if businessId == "" {
		helper.RetData(ctx, false, helper.BusinessIdErr)
		return
	}
	s, err := model.BusinessPromoInspectionList(uint(page), uint(pageSize), uid, businessId)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}

	helper.RetData(ctx, true, s)
}
